Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/reliable int mapping #30

Merged
merged 7 commits into from
Dec 18, 2024

Conversation

lmazz1-dbt
Copy link
Collaborator

@lmazz1-dbt lmazz1-dbt commented Dec 17, 2024

Context

We used to hash data rows, and assign to clusters of data rows an identity equal to the hash of all their children. We're now moving to a more compact representation, where data rows are given an integer key, and we want a unique way of mapping new clusters to new integer keys. This is made more tricky by the fact that we're parallelising the construction of hierarchical clusters.

Changes proposed in this pull request

  • Create IntMap data structure taking unordered sets of integers, and mapping them a to a key that 1) is a negative integer; 2) does not collide with other keys generated by other instances of this class, as long as they are initialised with a different salt.
  • A few small bug fixes

Guidance to review

The fact that keys are always negative means that it's possible to build a hierarchy where keys are themselves parts of keyed sets, and it's easy to distinguish integers mapped to raw data points (which will be non-negative), to integers that are keys to sets (which will be negative). The salt allows to work with a parallel execution model, where each worker maintains their separate key space, as long as each worker operates on disjoint subsets of positive integers. The salt and a key are combined via the Cantor pairing function.

Checklist:

  • My code follows the style guidelines of this project
  • New and existing unit tests pass locally with my changes

@lmazz1-dbt lmazz1-dbt changed the base branch from main to feature/new-ingest-process December 17, 2024 17:37
Copy link
Collaborator

@wpfl-dbt wpfl-dbt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple comments. I really should have put test_hierarchy in test/common -- one for later!

src/matchbox/common/hash.py Outdated Show resolved Hide resolved
src/matchbox/common/hash.py Outdated Show resolved Hide resolved
src/matchbox/common/hash.py Show resolved Hide resolved
src/matchbox/common/results.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@wpfl-dbt wpfl-dbt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last comment

src/matchbox/common/hash.py Show resolved Hide resolved
Copy link
Collaborator

@wpfl-dbt wpfl-dbt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

@lmazz1-dbt lmazz1-dbt merged commit 68445d9 into feature/new-ingest-process Dec 18, 2024
3 checks passed
@lmazz1-dbt lmazz1-dbt deleted the fix/reliable-int-mapping branch December 18, 2024 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants